import yaml
import os
from util.get_path import get_path


class ConfigHandler:
    def __init__(self):
        self.base_path = get_path()
        self.cf = self.get_config()

    def get_config(self):
        yaml_path = os.path.join(self.base_path, "param", "api.yaml")
        with open(yaml_path, "r", encoding="utf-8") as f:
            cfg = f.read()
        cf = yaml.safe_load(cfg)
        # cf["path"]["test_case"] = os.path.join(self.base_path, "test_case")
        return cf

    def get_login_path(self):
        return self.cf["api"]["login"]

    def get_case_path(self):
        return self.cf["test_case"]

    def get_houses(self):
        return self.cf["api"]["get_houses"]


if __name__ == '__main__':
    cf = ConfigHandler()
    print(cf.get_login_path())
    # print(cf.get_case_path())
